#!/bin/bash

#Script used to install or config zsh into system

export SYSTEM_GIT_HOME="$HOME/gitworkspace"

export LOCAL_ZSH_CONFIG_HOME="$HOME/gitworkspace/.dotfiles/lib/zsh/"


__install_oh_my_zsh_if_not_installed_yet(){

    if [[ ! -d ~/.oh-my-zsh ]]; then
        cd "$SYSTEM_GIT_HOME/oh-my-zsh"
        source ./tools/install.sh
    fi
}



__install_powerline_for_zsh_if_not_installed_yet(){

    if [[ ! -f ~/.oh-my-zsh/custom/themes/powerline.zsh-theme ]]; then
        cd "$SYSTEM_GIT_HOME/oh-my-zsh-powerline-theme"
        source ./install_in_omz.sh
    fi
}

__copy_local_zshrc_to_system_zshrc(){

    cd "$LOCAL_ZSH_CONFIG_HOME"
    if [[ ! -f ~/.zshrc  ]] ; then 
        cp ./.zshrc ~/.zshrc
    fi 
}

__return_to_invoking_dir(){

if [[ -z "${SYSTEM_CONFIG_HOME}" ]]; then
    echo "${SYSTEM_CONFIG_HOME} not exists"
    cd "$(dirname $0)"
else
    echo "${SYSTEM_CONFIG_HOME} exists"
    cd  $SYSTEM_CONFIG_HOME
fi
}

#
__install_oh_my_zsh_if_not_installed_yet
__install_powerline_for_zsh_if_not_installed_yet
__copy_local_zshrc_to_system_zshrc
__return_to_invoking_dir



